﻿using System.Drawing;

namespace PlusPlusPaint.Layers.VisualObjects
{
    abstract class DynamicallyGeneratedVisualObject : SizeAwareVisualObject
    {
        #region member variables
        protected const int MaximumDistanceToRecogniseOnClick = 5;
        private Color colour = Color.Transparent;
        private int brushSize = 1;
        #endregion

        #region properties
        public override bool CanDrawOn
        {
            get
            {
                return false;
            }
        }

        public override bool AcceptsMostText
        {
            get
            {
                return false;
            }
        }

        public Color Colour
        {
            get
            {
                return colour;
            }
            set
            {
                colour = value;
            }
        }

        public int BrushSize
        {
            get
            {
                return brushSize;
            }
            set
            {
                brushSize = value;
            }
        }
        #endregion

        #region overrides
        public override void Deserialize(SerializedObject node)
        {
            base.Deserialize(node);
            this.Colour = Color.FromArgb(node.NamedInts["colour"]);
        }

        public override SerializedObject Serialize()
        {
            SerializedObject so = base.Serialize();
            so.NamedInts["colour"] = Colour.ToArgb();
            return so;
        }
        #endregion
    }
}
